package com.ejlchina.tool.adapter

import android.annotation.SuppressLint
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.adolf.androiddemo.databinding.ItemIndexFixErrorBinding
import com.ejlchina.tool.network.IndexFixUpdateFailBean

class IndexFixFailDialogAdapter(private val dataList: List<IndexFixUpdateFailBean>): RecyclerView.Adapter<IndexFixFailDialogAdapter.IndexFixFailDialogViewHolder>() {


    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): IndexFixFailDialogViewHolder {
        val binding = ItemIndexFixErrorBinding.inflate(LayoutInflater.from(parent.context),parent,false)
        return IndexFixFailDialogViewHolder(binding)
    }

    override fun getItemCount(): Int {
        return dataList.size
    }

    override fun onBindViewHolder(holder: IndexFixFailDialogViewHolder, position: Int) {
        holder.bindData(dataList[position])
    }

    inner class IndexFixFailDialogViewHolder(private val binding: ItemIndexFixErrorBinding): RecyclerView.ViewHolder(binding.root){

        @SuppressLint("SetTextI18n")
        fun bindData(data: IndexFixUpdateFailBean){
            binding.tvMac.text ="MAC: ${data.mac} #${data.bucketNo}"
            binding.tvReason.text = "失败原因：${data.errMsg}"
        }
    }
}